<form class="layui-form" action="" id="user-modify-form"
      style="margin-top: 20px;margin-right:20px;">
    <div class="layui-form-item">
        <label class="layui-form-label">姓名：</label>
        <div class="layui-input-block">
            <input type="text" name="user_name" lay-verify="required" value="#(user.get('user_name'))" autocomplete="off" placeholder="请输入姓名" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">手机号：</label>
        <div class="layui-input-block">
            <input type="tel" name="user_phone" lay-verify="required" value="#(user.get('user_phone'))"
                   autocomplete="off" placeholder="请输入手机号" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">邮箱：</label>
        <div class="layui-input-block">
            <input type="tel" name="user_email" lay-verify="required" value="#(user.get('user_email'))"
                   autocomplete="off" placeholder="请输入邮箱" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">旧密码：</label>
        <div class="layui-input-block">
            <input type="password" name="user_password" placeholder="请输入旧密码（若不修改请留空）" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">新密码：</label>
        <div class="layui-input-block">
            <input type="password" name="user_new_password" placeholder="请输入新密码（若不修改请留空）" class="layui-input">
        </div>
    </div>


    <div class="detail_form_footer" >
        <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="user-modify-form-submit">更新</button>
        <button class="layui-btn layui-btn-primary" lay-filter="btn-user-modify-cancle" >关闭</button>
    </div>
</form>

<script>
    layui.$(function () {
        var form = layui.form, layer = layui.layer;
        form.render();

        var $window = layui.$('#user-modify-window').closest('.window'), $form = layui.$('#user-modify-form');
        $window.find('.btn-submit').click(function () {
            $form.find('button[lay-filter="user-modify-form-submit"]').trigger('click');
        });
        form.on('submit(user-modify-form-submit)', function (data) {
            layui.$.ajax({
                method: 'post',
                url: "/console/modifyUser",
                data: data.field,
                beforeSend: function () {
                },
                dataType: 'json',
                success: function (rs) {
                    if (rs.success) {
                        var user_name = layui.$("input[name='user_name']").val();
                        //上方导航联系人姓名修改
                        layui.$('#user-name-label').html(user_name);
                        layer.msg(rs.message, {
                            icon: 1
                        });
                        layer.closeAll('page');
                    } else {
                        layer.msg(rs.message, {
                            icon: 5
                        });
                    }
                }
            });
            return false;
        });

        /* 监听取消 */
        layui.$("[lay-filter=btn-user-modify-cancle]").click(function () {
            layer.closeAll("page");
        });

    });
</script>